package com.web.orderservice.client;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.web.orderservice.entity.PageVO;
import com.web.orderservice.entity.Product;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 调用商品服务的rest客户端
 */
@FeignClient(value = "product-service")
public interface ProductServiceFeignClient {

    @RequestMapping("/product/{id}")
    ResponseEntity<Product> findProductById(@PathVariable Integer id);

    @GetMapping("/products")
    ResponseEntity<List<Product>> findAllProducts();

    @GetMapping("/products-page")
    ResponseEntity<PageVO> findProductsPage(
            @RequestParam(value = "current",required = false,defaultValue = "1") Integer current,
            @RequestParam(value = "pageSize",required = false,defaultValue = "10") Integer pageSize);

    @PostMapping("/product")
    ResponseEntity<String> addProduct(@RequestBody Product product);

    @PutMapping("/product")
    ResponseEntity<String> updateProduct(@RequestBody Product product);

    @DeleteMapping("/product/{id}")
    ResponseEntity<String> deleteProduct(@PathVariable Integer id);
}
